#coding=gbk

import time
import ssh
import telnetlib
import traceback
import base64

while True:
	HOST="172.28.165.254"
	USER="monitor"
	PASSWD="IWNmZkV4MjAwN1w="
	try:
		tn = telnetlib.Telnet(HOST)
		tn.read_until("sername:")
		tn.write(USER+"\n")
		tn.read_until("assword:")
		tn.write(base64.decodestring(PASSWD)+"\n")
		tn.read_until("#")
		tn.write("show run \n")
		time.sleep(1)
		res=""
		out=""
		i=0
		while True:
			res=tn.read_very_eager()
			for line in res.split('\n'):
				if "More" not in line:
					out=out+line+"\n"
			if out[-2]=="#":
				tn.write("exit\n")
				break
			elif "More" in res:
				tn.write(" ")
				time.sleep(0.01)
			else:
				time.sleep(1)
				i=i+1
				if i > 10:
					break
		print out
		tn.close()
	except Exception:
		excinfo=traceback.format_exc()
		print excinfo

	break

#coding=gbk

import time
import ssh
import telnetlib
import traceback
import base64

while True:
	HOST="172.28.165.254"
	USER="monitor"
	PASSWD="IWNmZkV4MjAwN1w="
	try:
		tn = telnetlib.Telnet(HOST)
		tn.read_until("sername:")
		tn.write(USER+"\n")
		tn.read_until("assword:")
		tn.write(base64.decodestring(PASSWD)+"\n")
		tn.read_until("#")
		tn.write("show run \n")
		time.sleep(1)
		res=""
		out=""
		i=0
		while True:
			res=tn.read_very_eager()
			for line in res.split('\n'):
				if "More" not in line:
					out=out+line+"\n"
			if out[-2]=="#":
				tn.write("exit\n")
				break
			elif "More" in res:
				tn.write(" ")
				time.sleep(0.01)
			else:
				time.sleep(1)
				i=i+1
				if i > 10:
					break
		print out
		tn.close()
	except Exception:
		excinfo=traceback.format_exc()
		print excinfo

	break

